package com.wqiuqiu.gulimall.product.web;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.wqiuqiu.gulimall.product.service.SkuInfoService;
import com.wqiuqiu.gulimall.product.vo.SkuItemDetailVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.concurrent.ExecutionException;

@Controller
public class ItemController {

    @Autowired
    SkuInfoService skuInfoService;

    @GetMapping("/{skuId}.html")
    public String getItemDetail(@PathVariable("skuId") Long skuId, Model model){
        SkuItemDetailVo skuItemDetailVo = null;
        try {
            skuItemDetailVo = skuInfoService.item(skuId);
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        model.addAttribute("item",skuItemDetailVo);
        return "item";
    }
}
